/*
 * @Author: deng da chao
 * @Date: 2022-05-24 09:12:11
 * @LastEditTime: 2023-02-06 11:05:53
 * @Description: 
 */
/**
 * 校验规则
 */
import { regExp } from "./regExp";

/*
    判断参数内容是否为空
*/
function isEmpty(val) {
  if (isArray(val) || isString(val)) {
    return val.length === 0;
  }
  if (val instanceof Map || val instanceof Set) {
    return val.size === 0;
  }
  if (isObject(val)) {
    return Object.keys(val).length === 0;
  }
  return false;
}
/**
 * 屏蔽手机号
 */
function contractNumValidate(value) {
    value
  return value.replace(regExp.mobilePhoneMiddle, '$1****$2');
}

/**
 * 屏蔽哈希值
 * 前8位+10*+后6位
 */
 function encryptionHash(value,x,y,z) {
  if(!value || value == '') return '****'
  x = x ? x : 8;
  y = y ? y : '**********';
  z = z || z == 0 ? z : 6;

  let before = value.slice(0, x);
  let after = value.slice(value.length - z, value.length);
  return `${before}${y}${after}`;
}



/*
  验证身份证 true成功 false失败
*/
const cardValidate = (value)=>{
  return regExp.card.test(value)
}

export {
    isEmpty,
    contractNumValidate,
    encryptionHash,
    cardValidate
};
